#include <iostream>
using namespace std;
#include "Job.h"


unsigned int Job::m_jobCounter = INIT_JOB_ID; // initialize job counter

/***************************************************************************************
* function name: Job(const unsigned int startTime, const unsigned int length, const int priority)
* The Input: Values for new job's attributes
* The output: None
* The Function operation: Initializes new job's attributes' values as given job's.
* 						  Job counter is incremented
***************************************************************************************/
Job::Job(const unsigned int startTime, const unsigned int length, const int priority): m_jobID(m_jobCounter),
		m_startTime(startTime), m_priority(priority) {
	++m_jobCounter; // new job created, increment job counter


	//m_lastRunTime = INIT_LAST_RUN_TIME; // initialize last run time attribute // TODO DELETE
}

Job::Job(const Job& jobToCopy): m_jobID(jobToCopy.m_jobID), m_startTime(jobToCopy.m_startTime), m_priority(jobToCopy.m_priority) {
	// set new job's attributes as given job's
	m_length = jobToCopy.m_length;

	// m_lastRunTime = jobToCopy.m_lastRunTime; // DELETE

	// increment job counter
	++m_jobCounter;
}

/***************************************************************************************
* function name: ~Job()
* The Input: None
* The output: None
* The Function operation: Decrements job counter
***************************************************************************************/
Job::~Job() {
	--m_jobCounter;
}

/***************************************************************************************
* function name: virtual void work()
* The Input: None
* The output: None
* The Function operation: Prints out execution simulation
***************************************************************************************/
void Job::work(const int systemTime, const int type) {
	cout << "Time #" << systemTime << ": run job #" << m_jobID << ", type " << /*m_*/type << endl; // simulate working
	--m_length; // one time unit was given, decrease job's length
}
